/*-----------------------------------------------------------------------------
	The contents of this file are subject to the Mozilla Public License
	Version 1.1 (the "License"); you may not use this file except in
	compliance with the License.You may obtain a copy of the License at
	http://www.mozilla.org/MPL/MPL-1.1.html
	
	Software distributed under the License is distributed on an "AS IS"
	basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	License for the specific language governing rights and limitations
	under the License.
	
	The Original Code is Fever Framework code.
	
	The Initial Developer of the Original Code is Romain Ecarnot.
	Portions created by Initial Developer are Copyright (C) 2006
	the Initial Developer. All Rights Reserved.
	
	Contributor(s):
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
-----------------------------------------------------------------------------*/

import org.aswing.CursorManager;
import org.aswing.geom.Point;
import org.aswing.graphics.Graphics;
import org.aswing.graphics.SolidBrush;

import fvaswing.components.cursors.FvCursor;

/**
 * A cursor which can be used to notice 'link' elements. 
 * 
 * <p>There are 2 ways to use cursor.<br />
 * First, classic instantiation and <strong>AsWing CursorManager</strong> use.
 * {@code
 *   var cursor : FvLinkCursor = new FvLinkCursor();
 *   CursorManager.showCustomCursor( cursor );
 * }
 * 
 * Second, use direct {@link #show} method.
 * {@code
 *    FvLinkCursor.show();
 * }
 * 
 * @author Romain Ecarnot
 */
class fvaswing.components.cursors.FvLinkCursor extends FvCursor
{
	//-------------------------------------------------------------------------
	// Private properties
	//-------------------------------------------------------------------------
	
	private static var _instance : FvLinkCursor;
	
	
	//-------------------------------------------------------------------------
	// Public API
	//-------------------------------------------------------------------------
	
	/**
	 * Returns a unique <strong>FvLinkCursor</strong> instance.
	 */
	public static function getInstance() : FvLinkCursor
	{
		if( _instance == undefined ) _instance = new FvLinkCursor();
		return _instance;	
	}
	
	/**
	 * Shows cursor and hides the system cursor. 
	 */
	public static function show() : Void
	{
		CursorManager.showCustomCursor( getInstance() );
		CursorManager.hideSystemCursor();	
	}
	
	/**
	 * Hides cursor and shows the default system cursor. 
	 */
	public static function hide() : Void
	{
		CursorManager.hideCustomCursor( getInstance() );
		CursorManager.showSystemCursor();
	}
	
	/**
	 * Constructor.
	 * 
	 * <p>Cursor properties are initialized with constants values.
	 * <ul>
	 *   <li>{@link #CURSOR_COLOR}</li>
	 * </ul>
	 */
	public function FvLinkCursor()
	{
		super();
	}	
	
	/**
	 * Concrete drawing implementation.
	 */
	public function repaint() : Void
	{
		_paintBasicCursor();
		
		var circle : MovieClip = _container.createEmptyMovieClip( "__p__", 2 );
		var backBrush : SolidBrush = new SolidBrush( 0x808080, 100 );
		var crossBrush : SolidBrush = new SolidBrush( 0xffffff, 100 );
		var fx : Graphics = new Graphics( circle );
		fx.fillCircle( backBrush, 16, 11, 6 );
		
		var points : Array = 
		[
			new Point( 13, 8 ),
			new Point( 19, 8 ),			new Point( 19, 14 ),			new Point( 17, 12 ),			new Point( 13, 14 ),			new Point( 15, 10 )
			
		];
		
		fx.fillPolygon( crossBrush, points );
		
		_applyFilter();
	}
	
}